package com.itheima.sys.controller;


import com.itheima.common.vo.Result;
import com.itheima.sys.dto.SysUserDTO;
import com.itheima.sys.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 用户表 系统-用户表 前端控制器
 * </p>
 *
 * @author itheima
 * @since 2020-12-13
 */
@RestController
public class SysUserController {


    @Autowired
    private ISysUserService sysUserService;


    /**
     * 查询到用户
     * @param username 手机号/用户名
     * @return
     */
    @GetMapping("/user/query")
    public Result<SysUserDTO> querUser(@RequestParam("username") String username){
        return Result.success(sysUserService.querUser(username));
    }


    /**
     * 系统用户注册
     * @param sysUserDTO
     * @param checkcode
     * @return
     */
    @PostMapping("/user/register")
    public Result<Long> registerSysUser(SysUserDTO sysUserDTO, @RequestParam("checkcode") String checkcode){
        return Result.success(sysUserService.register(sysUserDTO, checkcode));
    }
}

